﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using Krile.Kernel.Control;
using System.Windows.Forms;

namespace Twinkle.Dialogs.Config
{
    public partial class General : ConfigPage
    {
        public General()
        {
            InitializeComponent();
        }

        private void General_Load(object sender, EventArgs e)
        {
            StatusCountPerRecv.Value = Kernel.Config.StatusCountPerRecv;
            GradualReceive.Checked = Kernel.Config.GradualReceive;
            RecvFavTimeline.Checked = Kernel.Config.RecvFavTimeline;
            ShowID.Checked = Kernel.Config.StatusDesign.ShowIDAlternative;
            ShowQTButton.Checked = Kernel.Config.StatusDesign.ShowQTButton;
            ShowRTButton.Checked = Kernel.Config.StatusDesign.ShowRTButton;
            RemoveSpaceRT.Checked = Kernel.Config.StatusDesign.RemoveSpaceRT;
            ShowUnofficialRTButton.Checked = Kernel.Config.StatusDesign.ShowUnofficialRTButton;
            DMColorBtn.ForeColor = Kernel.Config.StatusDesign.DMTextColor;
            DMColorBtn.BackColor = Kernel.Config.StatusDesign.DMBackColor;
        }

        public override void Apply()
        {
            Kernel.Config.StatusCountPerRecv = (int)StatusCountPerRecv.Value;
            Kernel.Config.GradualReceive = GradualReceive.Checked;
            Kernel.Config.RecvFavTimeline = RecvFavTimeline.Checked;
            Kernel.Config.StatusDesign.ShowIDAlternative = ShowID.Checked;
            Kernel.Config.StatusDesign.ShowQTButton = ShowQTButton.Checked;
            Kernel.Config.StatusDesign.ShowRTButton = ShowRTButton.Checked;
            Kernel.Config.StatusDesign.RemoveSpaceRT = RemoveSpaceRT.Checked;
            Kernel.Config.StatusDesign.ShowUnofficialRTButton = ShowUnofficialRTButton.Checked;
            Kernel.Config.StatusDesign.DMTextColor = DMColorBtn.ForeColor;
            Kernel.Config.StatusDesign.DMBackColor = DMColorBtn.BackColor;
        }

        private void showAccountMngr_Click(object sender, EventArgs e)
        {
            using (var am = new Dialogs.Account.AccountsManager())
            {
                am.ShowDialog();
            }
        }

        private void DMColorBtn_Click(object sender, EventArgs e)
        {
            colorsContext.Show(DMColorBtn, new Point(0, DMColorBtn.Height));
        }

        private void selectTextColorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var cd = new ColorDialog())
            {
                if (cd.ShowDialog() == DialogResult.OK)
                    DMColorBtn.ForeColor = cd.Color;
            }
        }

        private void selectBackColorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var cd = new ColorDialog())
            {
                if (cd.ShowDialog() == DialogResult.OK)
                    DMColorBtn.BackColor = cd.Color;
            }
        }
    }
}
